//
//  HomePageVC.m
//  HappyRent
//
//  Created by CoderYee on 2017/3/29.
//  Copyright © 2017年 内圈科技. All rights reserved.
//

#import "HomePageVC.h"    //首页VC
#import "Detail_MapVC.h"  //地图VC
#import "Home_DetailVC.h" //详情
#import "Home_TypeTableCell.h"
#import "Home_headerView.h"

@interface HomePageVC ()

@end

@implementation HomePageVC

-(void)viewWillAppear:(BOOL)animated{
    
    [super viewWillAppear:animated];
}
-(void)viewWillDisappear:(BOOL)animated{
    
    [super viewWillDisappear:animated];
}
-(void)addOwnViews{
    
    [super addOwnViews];
    [self addHeaderView];
}
-(void)configOwnViews{
    
    [self.tableView setFrame:CGRectMake(0, 0, kMainScreenWidth, KcontentViewHeight-49)];

    [self tablePullupHeaderRefresh:^{
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            
            [self tableViewEndRefresh];
        });
    }];
    
    [self tablePullDownFootRefresh:^{
      
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            
            [self tableViewEndRefresh];
        });
        
    }];
}
-(void)addHeaderView{
    
    Home_headerView  *headerView=[[Home_headerView alloc] initWithFrame:CGRectMake(0, 0, kMainScreenWidth, KcontentViewHeight-49)];
    self .tableView.tableHeaderView=headerView;
}
-(void)registerCellClass{
    
    [super registerCellClass];
    [self.tableView registerClass:[Home_TypeTableCell class] forCellReuseIdentifier:[Home_TypeTableCell cellIdentifier]];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 4;
}
#pragma mark  UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    Home_TypeTableCell *cell=[tableView dequeueReusableCellWithIdentifier:[Home_TypeTableCell cellIdentifier] forIndexPath:indexPath];
    [cell configTableCellindexPath:indexPath];
    return cell;
}
-(UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *view=[[UIView alloc] init];
    return view;
}
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0, kMainScreenWidth, 0.01)];
    return view;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 6.0f;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.01;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return kMainScreenWidth*0.5+60;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    Home_DetailVC *detailVc=[[Home_DetailVC alloc] init];
    detailVc.hidesBottomBarWhenPushed=YES;
    [self.navigationController pushViewController:detailVc animated:YES];

}
@end
